﻿using System;
using System.Collections.Generic;
using System.Text;

public delegate void ScoreChangeDelegate(object i_Obj);

public class Player
{
    private const int k_MinAsciiValue = 49;
    private int m_Score = 0;
    private char? m_PlayerSymbol = null;
    private Random m_Random = null;

    public char? PlayerSymbol
    {
        get { return m_PlayerSymbol; }
    }

    public int Score
    {
        get { return m_Score; }
        set 
        { 
            m_Score = value; 
            OnScoreChange(); 
        }
    }

    public event ScoreChangeDelegate ScoreChange;

    protected virtual void OnScoreChange()
    {
        if (ScoreChange != null)
        {
            ScoreChange.Invoke(this);
        }
    }

    private ePlayerType? m_PlayerType = null;

    public Player(ePlayerType i_PlayerType, char i_PlayerSymbol)
    {
        m_PlayerType = i_PlayerType;
        m_PlayerSymbol = i_PlayerSymbol;
    }

    public ePlayerType GetPlayerType
    {
        get { return m_PlayerType.Value; }
        set { m_PlayerType = value; }
    }

    public enum ePlayerType
    {
        User = 1,
        Pc = 2
    }

    public char PlayRound(int i_MaxColumnValue)
    {
        if (m_Random == null)
        {
            m_Random = new Random();
        }

        i_MaxColumnValue += (int)'0';
        int PlayerMove = m_Random.Next(k_MinAsciiValue, i_MaxColumnValue);

        return Convert.ToChar(PlayerMove);
    }
}
